package cn.taoticket.service;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import cn.taoticket.mapper.TaoticketOrderMapper;
import cn.taoticket.pojo.TaoticketOrder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by taoticket
 */
@RestController
public class RestTaoticketOrderService {

     @Resource
     private TaoticketOrderMapper taoticketOrderMapper;

     @RequestMapping(value = "/getTaoticketOrderById",method = RequestMethod.POST)
     public TaoticketOrder getTaoticketOrderById(@RequestParam("id") Long id)throws Exception{
        return taoticketOrderMapper.getTaoticketOrderById(id);
     }

     @RequestMapping(value = "/getTaoticketOrderListByMap",method = RequestMethod.POST)
     public List<TaoticketOrder> getTaoticketOrderListByMap(@RequestParam Map<String,Object> param)throws Exception{
        return taoticketOrderMapper.getTaoticketOrderListByMap(param);
     }

     @RequestMapping(value = "/getTaoticketOrderCountByMap",method = RequestMethod.POST)
     public Integer getTaoticketOrderCountByMap(@RequestParam Map<String,Object> param)throws Exception{
        return taoticketOrderMapper.getTaoticketOrderCountByMap(param);
     }

     @RequestMapping(value = "/qdtxAddTaoticketOrder",method = RequestMethod.POST)
     public Long qdtxAddTaoticketOrder(@RequestBody TaoticketOrder taoticketOrder)throws Exception{
        taoticketOrder.setCreatedTime(new Date());
        taoticketOrderMapper.insertTaoticketOrder(taoticketOrder);
        return taoticketOrder.getId();
     }

     @RequestMapping(value = "/qdtxModifyTaoticketOrder",method = RequestMethod.POST)
     public Long qdtxModifyTaoticketOrder(@RequestBody TaoticketOrder taoticketOrder)throws Exception{
        taoticketOrder.setUpdatedTime(new Date());
        taoticketOrderMapper.updateTaoticketOrder(taoticketOrder);
        return taoticketOrder.getId();
     }
}
